package com.jinmdz.fmis.dao.dao;

import com.jinmdz.fmis.dao.model.transport.TransportCarItem;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.ArrayList;

/**
 * 车辆Dao
 *
 * @author LiCongLu
 * @date 2020-02-11 15:16
 */
public interface TransportCarDao {

    /**
     * 按照类型编码查询车辆信息
     *
     * @param typeCode 车辆类型编码
     * @return
     * @author LiCongLu
     * @date 2020-02-11 15:19
     */
    @Select(" select id,car_type_code,car_belong_code,car_code,car_no,transport_price,disable_state,driver_user_id,sort,remark,version " +
            " from transport_car where car_type_code = #{typeCode} and deleted=0 ")
    ArrayList<TransportCarItem> listTransportCarByTypeCode(@Param("typeCode") Integer typeCode);

    /**
     * 按照类型编码查询车辆信息
     *
     * @param typeCode 车辆类型编码
     * @param id       旧车辆主键
     * @return
     * @author LiCongLu
     * @date 2020-02-11 15:19
     */
    @Select(" select id,car_type_code,car_belong_code,car_code,car_no,transport_price,disable_state,driver_user_id,sort,remark,version " +
            " from transport_car where  car_type_code = #{typeCode} and deleted=0  union " +
            " select id,car_type_code,car_belong_code,car_code,car_no,transport_price,1 as disable_state,driver_user_id,sort,remark,version " +
            " from transport_car where  (car_type_code != #{typeCode} and  id=#{id} )  ")
    ArrayList<TransportCarItem> listTransportCarByTypeCodeAndOldCarId(@Param("typeCode") Integer typeCode, @Param("id") Integer id);

}
